# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=autopsy
pkgver=4.22.1
_skver=4.14.0
pkgrel=1
epoch=1
pkgdesc='The forensic browser. A GUI for the Sleuth Kit.'
groups=('blackarch' 'blackarch-forensic')
arch=('x86_64')
url='https://github.com/sleuthkit/autopsy'
license=('MIT' 'Apache')
depends=('java-runtime' 'testdisk' 'sleuthkit' 'sleuthkit-java' 'python-pytsk3')
source=("https://github.com/sleuthkit/autopsy/releases/download/$pkgname-$pkgver/$pkgname-${pkgver}_v2.zip"
        "$pkgname.desktop")
sha512sums=('5ec4dc6bdfbc23506ef6ab86e322a64de802772abdea9c16c9c66f74d90cc909e4039377bcec2c74e32c2cbc220af7f2b0e79ea8caa54d49fa964d2d4012e7ab'
            '08f98e0b4cc2f0791a4543ce77ec1a40214f9358973e2431e6b253d32e9954ee1998d61d234168699802a091de901b0661dffe1243ccb35fd299648d65b1907b')

package() {
  cd "$pkgname-$pkgver"

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/opt/$pkgname"

  cp -r * "$pkgdir/opt/$pkgname/"

  rm -f \
    "$pkgdir/opt/$pkgname/$pkgname/modules/ext/sleuthkit-postgresql-$_skver.jar"
  ln -sf "/usr/share/java/sleuthkit-$_skver.jar" \
    "$pkgdir/opt/$pkgname/$pkgname/modules/ext/sleuthkit-postgresql-$_skver.jar"
  ln -sf "/usr/share/java/sleuthkit-$_skver.jar" \
    "$pkgdir/opt/autopsy/autopsy/modules/ext/sleuthkit-$_skver.jar"

  install -m 755 "bin/$pkgname" "$pkgdir/opt/$pkgname/bin/$pkgname"
  install -Dm 644 icon.ico "$pkgdir/usr/share/pixmaps/$pkgname.ico"
  install -Dm 644 "$srcdir/$pkgname.desktop" \
    "$pkgdir/usr/share/applications/$pkgname.desktop"

  ln -sf "/opt/$pkgname/bin/$pkgname" "$pkgdir/usr/bin/$pkgname"
}

